import { WeaTools, WeaLocaleProvider } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

const { INPUT, SELECT, TEXTAREA } = WeaTools.types;

export default (app,myGroups,notMine,selectedGroupType) => {
	const {
		name = '',
		descriptionspan = '',
		groupid = selectedGroupType == '-2' ? '' : selectedGroupType
	} = app;
	const isNew = !name;

	return [{
		items: [
			{
				conditionType: INPUT,
				rules: "required",
				domkey: ["name"],
				label: getLabel(502690, '名称'),
				value: name
			},
			isNew && {
				conditionType: SELECT,
				detailtype: 1,
				domkey: ["displayType"],
				label: getLabel('17139', '显示类型')
			},
			isNew && {
				conditionType: SELECT,
				detailtype: 3,
				domkey: ["fillinType"],
				label: getLabel('502749', '填报类型')
			},
			{
				conditionType: TEXTAREA,
				domkey: ["description"],
				label: getLabel(502497, '描述'),
				minRows: 5,
				maxRows: 5,
				value: descriptionspan.replace(new RegExp("<br>", ("gm")), "\n")
			},
			//notMine !='1' && !isNew && 
			{
				conditionType: SELECT,
				detailtype: 1,
				rules: "required",
				options:myGroups,
				domkey: ["groupid"],
				label: '应用分组',
				value:groupid
			}
		].filter(Boolean),
		defaultshow: true
	}];
}

export const shareCondition = [{
	colSpan: 2,
	conditionType: SELECT,
	domkey: ['shareType'],
	fieldcol: 18,
	label: getLabel('505961', '共享类型'),
	labelcol: 6,
	viewAttr: 2,
	className: "edc-share-type-select",
	options: [{
		key: '1',
		showname: getLabel('30042', '人员')
	}, {
		key: '5',
		showname: getLabel('505963', '所有人'),
		selected: true,
	}, {
		key: '2',
		showname: getLabel('505976', '分部'),
	}, {
		key: '3',
		showname: getLabel('505977', '部门'),
	}, {
		key: "6",
		selected: false,
		showname: getLabel('6086', '岗位'),
	}, {
		key: "4",
		selected: false,
		showname: getLabel(122, "角色"),
	}]
}, {
	1: [[{
		browserConditionParam: {
			completeParams: {},
			conditionDataParams: {},
			dataParams: {},
			destDataParams: {},
			hasAddBtn: false,
			hasAdvanceSerach: true,
			idSeparator: ",",
			isAutoComplete: 1,
			isDetail: 0,
			isMultCheckbox: false,
			isSingle: false,
			pageSize: 10,
			quickSearchName: "",
			replaceDatas: [],
			type: "17",
			viewAttr: 3,
			title: getLabel('505966', '选择人员')
		},
		colSpan: 2,
		conditionType: "BROWSER",
		domkey: ["content"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505966', '选择人员'),
		labelcol: 6,
		viewAttr: 3,
	}], [{
		olSpan: 2,
		conditionType: "SELECT",
		domkey: ["rightType"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505962', '权限'),
		labelcol: 6,
		options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('60', '维护') }],
		viewAttr: 2,
	}]],
	2: [[{
		browserConditionParam: {
			completeParams: {},
			conditionDataParams: {},
			dataParams: {},
			destDataParams: {},
			hasAddBtn: false,
			hasAdvanceSerach: true,
			idSeparator: ",",
			isAutoComplete: 1,
			isDetail: 0,
			isMultCheckbox: false,
			isSingle: false,
			pageSize: 10,
			quickSearchName: "",
			replaceDatas: [],
			type: "194",
			viewAttr: 3,
			title: getLabel('505970', '选择分部'),
			icon: "icon-coms-hrm",
			iconBgcolor: "#217346",
			linkUrl: "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=subcompany&id=",
			tabs: [{
				"key": "2",
				"name": getLabel('505968', '组织结构'),
				"dataURL": null,
				"dataParams": null,
				"isSearch": false,
				"showOrder": 0,
				"selected": false
			}, {
				"key": "1",
				"name": getLabel('505969', '按列表'),
				"dataURL": null,
				"dataParams": {
					"list": "1"
				},
				"isSearch": true,
				"showOrder": 0,
				"selected": false
			}],
			"isMultCheckbox": false,
			"hasBorder": false,
			"showCheckStrictly": true,
			"checkStrictly": true,
			"hideVirtualOrg": false,
			"expandfirstnode": false,
			"asynLoadAll": false,
			"defaultExpandedLevel": 0,
		},
		colSpan: 2,
		conditionType: "BROWSER",
		domkey: ["content"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505970', '选择分部'),
		labelcol: 6,
		viewAttr: 3,
	}, {
		"colSpan": 2,
		"conditionType": "CHECKBOX",
		"domkey": [
			"includesub"
		],
		"fieldcol": 18,
		"isQuickSearch": false,
		"label": getLabel('505971', '含下级'),
		"labelcol": 6,
		"viewAttr": 2
	}], [{
		colSpan: 2,
		conditionType: "INPUT_INTERVAL",
		domkey: ["sec1", "sec2"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel(683, "安全级别"),
		labelcol: 6,
		value: [10, 100],
		viewAttr: 2,
	}], [{
		olSpan: 2,
		conditionType: "SELECT",
		domkey: ["rightType"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505962', '权限'),
		labelcol: 6,
		options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('60', '维护') }],
		viewAttr: 2,
	}]],
	3: [[{
		browserConditionParam: {
			completeParams: {},
			conditionDataParams: {},
			dataParams: {},
			destDataParams: {},
			hasAddBtn: false,
			hasAdvanceSerach: true,
			idSeparator: ",",
			isAutoComplete: 1,
			isDetail: 0,
			isMultCheckbox: false,
			isSingle: false,
			pageSize: 10,
			quickSearchName: "",
			replaceDatas: [],
			type: "57",
			viewAttr: 3,
			title: getLabel('505972', '选择部门'),
			icon: "icon-coms-hrm",
			iconBgcolor: "#217346",
			linkUrl: "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=department&id=",
			tabs: [{
				"key": "2",
				"name": getLabel('505968', '组织结构'),
				"dataURL": null,
				"dataParams": null,
				"isSearch": false,
				"showOrder": 0,
				"selected": false
			}, {
				"key": "1",
				"name": getLabel('505969', '按列表'),
				"dataURL": null,
				"dataParams": {
					"list": "1"
				},
				"isSearch": true,
				"showOrder": 0,
				"selected": false
			}],
			hasBorder: false,
			showCheckStrictly: true,
			checkStrictly: true,
			hideVirtualOrg: false,
			expandfirstnode: false,
			asynLoadAll: false,
			defaultExpandedLevel: 0,
		},
		colSpan: 2,
		conditionType: "BROWSER",
		domkey: ["content"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505972', '选择部门'),
		labelcol: 6,
		viewAttr: 3,

	}, {
		"colSpan": 2,
		"conditionType": "CHECKBOX",
		"domkey": [
			"includesub"
		],
		"fieldcol": 18,
		"isQuickSearch": false,
		"label": getLabel('505971', '含下级'),
		"labelcol": 6,
		"viewAttr": 2
	}], [{
		colSpan: 2,
		conditionType: "INPUT_INTERVAL",
		domkey: ["sec1", "sec2"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel(683, "安全级别"),
		labelcol: 6,
		value: [10, 100],
		viewAttr: 2,
	}], [{
		olSpan: 2,
		conditionType: "SELECT",
		domkey: ["rightType"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505962', '权限'),
		labelcol: 6,
		options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('60', '维护') }],
		viewAttr: 2,
	}]],
	4: [[{
		browserConditionParam: {
			completeParams: {},
			conditionDataParams: {},
			dataParams: {},
			destDataParams: {},
			hasAddBtn: false,
			hasAdvanceSerach: true,
			idSeparator: ",",
			isAutoComplete: 1,
			isDetail: 0,
			isMultCheckbox: false,
			isSingle: false,
			pageSize: 10,
			quickSearchName: "",
			replaceDatas: [],
			type: "65",
			viewAttr: 3,
			title: getLabel('505973', '选择角色')
		},
		colSpan: 2,
		conditionType: "BROWSER",
		domkey: ["content"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505973', '选择角色'),
		labelcol: 6,
		viewAttr: 3,
	}], [{
		colSpan: 2,
		conditionType: "SELECT",
		domkey: ["rolelevel"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505974', '级别'),
		labelcol: 6,
		viewAttr: 2,
		options: [{
			key: '0',
			showname: getLabel('505975', '部门'),
			selected: true
		}, {
			key: '1',
			showname: getLabel('505976', '分部'),
		}, {
			key: '2',
			showname: getLabel('505977', '总部'),
		}]
	}], [{
		colSpan: 2,
		conditionType: "INPUT_INTERVAL",
		domkey: ["sec1", "sec2"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel(683, "安全级别"),
		labelcol: 6,
		value: [10, 100],
		viewAttr: 2,
	}], [{
		olSpan: 2,
		conditionType: "SELECT",
		domkey: ["rightType"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505962', '权限'),
		labelcol: 6,
		options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('60', '维护') }],
		viewAttr: 2,
	}]],
	5: [[{
		colSpan: 2,
		conditionType: "INPUT_INTERVAL",
		domkey: ["sec1", "sec2"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel(683, "安全级别"),
		labelcol: 6,
		value: [10, 100],
		viewAttr: 2,
	}], [{
		olSpan: 2,
		conditionType: "SELECT",
		domkey: ["rightType"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505962', '权限'),
		labelcol: 6,
		options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('60', '维护') }],
		viewAttr: 2,
	}]],
	6: [[{
		browserConditionParam: {
			completeParams: {},
			conditionDataParams: {},
			dataParams: {},
			destDataParams: {},
			hasAddBtn: false,
			hasAdvanceSerach: true,
			idSeparator: ",",
			isAutoComplete: 1,
			isDetail: 0,
			isMultCheckbox: false,
			isSingle: false,
			pageSize: 10,
			quickSearchName: "",
			replaceDatas: [],
			type: "278",
			viewAttr: 3,
			title: getLabel('505978', '选择岗位')
		},
		colSpan: 2,
		conditionType: "BROWSER",
		domkey: ["content"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505978', '选择岗位'),
		labelcol: 6,
		viewAttr: 3,
	}], [{
		colSpan: 2,
		conditionType: "SELECT_LINKAGE",
		domkey: ["joblevel"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505979', '岗位级别'),
		labelcol: 6,
		viewAttr: 2,
		options: [{
			key: '1',
			showname: getLabel('505975', '总部'),
			selected: true
		}, {
			key: '2',
			showname: getLabel('505980', '指定分部'),
		}, {
			key: '3',
			showname: getLabel('505981', '指定部门'),
		}],
		"selectLinkageDatas": {
			"3": {
				"browserConditionParam": {
					asynLoadAll: false,
                        "checkStrictly": true,
                        "completeParams": {},
                        "conditionDataParams": {},
                        "dataParams": {},
                        "defaultExpandedLevel": 0,
                        "destDataParams": {},
                        "expandfirstnode": false,
                        "hasAddBtn": false,
                        "hasAdvanceSerach": true,
                        "hasBorder": false,
                        "hideVirtualOrg": false,
                        "icon": "icon-coms-hrm",
                        "iconBgcolor": "#217346",
                        "idSeparator": ",",
                        "isAutoComplete": 1,
                        "isDetail": 0,
                        "isMultCheckbox": false,
                        "isSingle": false,
                        "linkUrl": "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=department&id=",
                        "pageSize": 10,
                        "quickSearchName": "",
                        "replaceDatas": [],
                        "showCheckStrictly": true,
                        "tabs": [{
                            "isSearch": false,
                            "key": "2",
                            "name": getLabel('25332', '组织结构'),
                            "selected": false,
                            "showOrder": 0
                        }, {
                            "dataParams": {
                                "list": "1"
                            },
                            "isSearch": true,
                            "key": "1",
                            "name": getLabel('130619', '按列表'),
                            "selected": false,
                            "showOrder": 0
                        }],
                        "title": getLabel('505972', '选择部门'),
                        "type": "57",
                        "viewAttr": 3
				},
				"colSpan": 2,
				"conditionType": "BROWSER",
				"domkey": [
					"jobdepartment"
				],
				"fieldcol": 18,
				"isQuickSearch": false,
				"label": "",
				"labelcol": 6,
				"viewAttr": 3
			},
			"2": {
				"browserConditionParam": {
					"asynLoadAll": false,
					"checkStrictly": true,
					"completeParams": {},
					"conditionDataParams": {},
					"dataParams": {},
					"defaultExpandedLevel": 0,
					"destDataParams": {},
					"expandfirstnode": false,
					"hasAddBtn": false,
					"hasAdvanceSerach": true,
					"hasBorder": false,
					"hideVirtualOrg": false,
					"icon": "icon-coms-hrm",
					"iconBgcolor": "#217346",
					"idSeparator": ",",
					"isAutoComplete": 1,
					"isDetail": 0,
					"isMultCheckbox": false,
					"isSingle": false,
					"linkUrl": "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=subcompany&id=",
					"pageSize": 10,
					"quickSearchName": "",
					"replaceDatas": [],
					"showCheckStrictly": true,
					"tabs": [{
						"isSearch": false,
						"key": "2",
						"name": getLabel('25332', '组织结构'),
						"selected": false,
						"showOrder": 0
					}, {
						"dataParams": {
							"list": "1"
						},
						"isSearch": true,
						"key": "1",
						"name": getLabel('130619', '按列表'),
						"selected": false,
						"showOrder": 0
					}],
					"title": getLabel('505970', '选择分部'),
					"type": "194",
					"viewAttr": 3
				},
				"colSpan": 2,
				"conditionType": "BROWSER",
				"domkey": [
					"jobsubcompany"
				],
				"fieldcol": 18,
				"isQuickSearch": false,
				"label": "",
				"labelcol": 6,
				"viewAttr": 3
			}
		},
	}], [{
		colSpan: 2,
		conditionType: "INPUT_INTERVAL",
		domkey: ["sec1", "sec2"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel(683, "安全级别"),
		labelcol: 6,
		value: [10, 100],
		viewAttr: 2,
	}], [{
		olSpan: 2,
		conditionType: "SELECT",
		domkey: ["rightType"],
		fieldcol: 18,
		isQuickSearch: false,
		label: getLabel('505962', '权限'),
		labelcol: 6,
		options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('60', '维护') }],
		viewAttr: 2,
	}]]
}];